package ird.demo.repository;

import ird.demo.domain.Transaction;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface TransactionRepository extends BaseRepository< Transaction, String>{
	@Query(value = "FROM Transaction WHERE id.tranId in (select a.id.tranId from UsrGrpTran a, Menu b where a.id.menuId=b.id.menuId and b.menuSuppInd='0' and a.id.usrGrp=:usrGrp)")
	public List<Transaction> findTranInMenuByUsrGrp(@Param("usrGrp") String usrGrp);
	
	@Query(value = "FROM Transaction WHERE id.tranId in (select a.id.tranId from TranGrpTran a, UsrGrpTranGrp b where a.id.tranGrp=b.id.tranGrp and b.id.usrGrp=:usrGrp)")
	public List<Transaction> findTranInTranGrpByUsrGrp(@Param("usrGrp") String usrGrp);
	
	@Query(value = "FROM Transaction WHERE id.tranId in (select id.tranId from TranGrpTran where id.tranGrp=:tranGrp)")
	public List<Transaction> findTranByTranGrp(@Param("tranGrp") String tranGrp);
	
	@Query(value = "FROM Transaction WHERE tranSuppInd='0' and menuId=:menuId order by tranId")
	public List<Transaction> findTranInByMenuId(@Param("menuId") String menuId);
	
	@Query(value = "FROM Transaction order by tranId")
	public List<Transaction> findAllTran();
	
}